import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface searchIndexSlice {
    activityDataParams: any
}

const initialState: searchIndexSlice = {
    activityDataParams: {},
};

const searchIndexSlice = createSlice({
    name: 'searchIndex',
    initialState,
    reducers: {
        setActivityData(state, action) {
            state.activityDataParams = {
                ...state.activityDataParams,
                ...action.payload,
            }
        },
        removeActivityDataByKey(state, action) {
            const obj = state.activityDataParams;
            delete obj[action.payload.key];
            state.activityDataParams = obj;
        },
    },
});

export const { setActivityData, removeActivityDataByKey } = searchIndexSlice.actions;
export default searchIndexSlice.reducer;
